<?php
session_start();
require_once( 'configs/config.php' );
require_once( 'lib/db.php' );

if( !$_GET['id'] )
{
	echo 'No ID';
	exit;
}
else
{
	$id = $_GET['id'];
}

// Get list of tables from current database..
$payment = $db->get_row('SELECT UserUID, Amount, Date, Reason FROM payments WHERE PaymentUID = ' . $id);

// Print out last query and results..
//$db->debug();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
		<title><?php echo $config['Name']; ?> | Edit a Payment</title>
		<link rel="stylesheet" href="style.css" type="text/css"></link>
	</head>
	<body>
<?php include_once('header.php'); ?>

			<div class="title">
				<h1>Edit a Payment</h1>
			</div>

			<form action="editPaymentProcess.php?id=<?php echo $id; ?>" method="post" id="accountForm" class="forms">
				<fieldset>
					<legend>Edit a Payment</legend>
					<label for="Person">Person</label>
					<select name="Person">
<?php
$users = $db->get_results('SELECT UserUID, FirstName, LastName FROM users ORDER BY FirstName asc, LastName asc');
foreach ( $users as $user )
{
?>
						<option value="<?php echo $user->UserUID; ?>"<?php if($user->UserUID == $payment->UserUID) echo ' selected="selected"';?>><?php echo $user->FirstName, ' ' , $user->LastName; ?></option>
<?php
}
?>
					</select>

					<label for="Amount">Amount</label>
					<input id="Amount" name="Amount" type="text" value="<?php echo $payment->Amount; ?>" />

					<label for="Reason">Reason</label>
					<textarea id="Reason" name="Reason"><?php echo $payment->Reason; ?></textarea>

					<label for="Date">Date</label>
					<input id="Date" name="Date" type="text" value="<?php echo $payment->Date; ?>" />

					<input type="submit" id="submit" value="Done Editing" />
				</fieldset>
			</form>

<?php include_once('footer.php'); ?>
	</body>
</html>